from socket import *
import time

ip_port = ('127.0.0.1', 2000)
back_log = 5
buffer_size = 1024

tcp_client = socket(AF_INET, SOCK_STREAM)
tcp_client.connect(ip_port)

while True:
    msg = 'I am alive'
    tcp_client.sendall(msg.encode())
    data = tcp_client.recv(buffer_size)
    print("服务器命令执行的结果是:", data.decode())
    time.sleep(5)

tcp_client.close()
